package com.jinzhi.jzweb.service.impl;

import com.baomidou.mybatisplus.plugins.Page;
import com.jinzhi.common.base.CoreServiceImpl;
import com.jinzhi.jzapi.certificate.pojo.MyResultsVo;
import com.jinzhi.jzweb.dao.ExaminationResultsComDao;
import com.jinzhi.jzweb.dao.ExaminationResultsIm4Mp4ComDao;
import com.jinzhi.jzweb.domain.ExaminationResultsComDO;
import com.jinzhi.jzweb.domain.ExaminationResultsComResourcesDO;
import com.jinzhi.jzweb.pojo.*;
import com.jinzhi.jzweb.service.ExaminationResultsComService;
import com.jinzhi.jzweb.service.ExaminationResultsImgMp4ComService;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * 
 * <pre>
 * 考试   成绩
 * </pre>
 * <small> 2020-02-24 21:00:12 | lance</small>
 */
@Service
public class ExaminationResultsImgMp4ComServiceImpl extends CoreServiceImpl<ExaminationResultsIm4Mp4ComDao, ExaminationResultsComResourcesDO> implements ExaminationResultsImgMp4ComService {

    @Autowired
    private ExaminationResultsImgMp4ComService imgMp4ComService;

    @Override
    public boolean saves(ResultsImgMp4Vo resultsImgMp4Vo) {
        ExaminationResultsComResourcesDO resultsComResourcesDO=imgMp4ComService.findOneByKv("results_id",resultsImgMp4Vo.getIds());
        if(resultsComResourcesDO==null){
            ExaminationResultsComResourcesDO comResourcesDO=new ExaminationResultsComResourcesDO();
            comResourcesDO.setResultsId(resultsImgMp4Vo.getIds());
            if(StringUtils.isNotBlank(resultsImgMp4Vo.getScoingb1img())){
                comResourcesDO.setScoingb1img(resultsImgMp4Vo.getScoingb1img());


            }
            if(StringUtils.isNotBlank(resultsImgMp4Vo.getScoingb1smp4())) {
                comResourcesDO.setScoingb1smp4(resultsImgMp4Vo.getScoingb1smp4());
            }
                boolean b=  imgMp4ComService.insert(comResourcesDO);
            return b;
        }else {
            if(StringUtils.isNotBlank(resultsImgMp4Vo.getScoingb1img())){
                resultsComResourcesDO.setScoingb1img(resultsImgMp4Vo.getScoingb1img());
            }
            if(StringUtils.isNotBlank(resultsImgMp4Vo.getScoingb1smp4())){
                resultsComResourcesDO.setScoingb1smp4(resultsImgMp4Vo.getScoingb1smp4());
            }
           boolean b= imgMp4ComService.updateById(resultsComResourcesDO);
            return b;
        }


    }
}
